package top.chmin.project.cloud.sys.relate.info;
import java.util.stream.Stream;
import java.util.List;
import java.util.ArrayList;

import top.chmin.project.cloud.common.*;
import lombok.experimental.Accessors;
import lombok.Setter;
import lombok.Getter;



/**
 * chmin
 * 2024-01-26 14:02:31
 * cloud-code
 */
public class RelateInfoCondition extends Condition {
    private RelateInfoCondition parent = null;

    RelateInfoCondition() {
    }

    private RelateInfoCondition(RelateInfoCondition condition) {
        this.parent = condition;
    }

    public static RelateInfoCondition forDelete() {
        RelateInfoCondition condition = new RelateInfoCondition();
        condition.setSql("DELETE FROM sys_relate_info#where##group##order##limit#");
        return condition;
    }

    public static RelateInfoCondition forSelect() {
        RelateInfoCondition condition = new RelateInfoCondition();
        condition.modelClass = RelateInfo.class;
        condition.setSql("SELECT #select# FROM sys_relate_info#where##group##order##limit#");
        return condition;
    }

    public RelateInfoCondition distinct() {
        this.distinct = true;
        return this;
    }

    public RelateInfoCondition limit(int limit) {
        this.limit = " LIMIT " + limit;
        return this;
    }

    public RelateInfoCondition sub() {
        return new RelateInfoCondition(this);
    }

    public RelateInfoCondition finish() {
        if (!whereList.isEmpty()) {
            parent.whereList.add("(" + String.join(" OR ", whereList) + ")");
        }
        parent.whereValueList.addAll(whereValueList);
        return parent;
    }

    public RelateInfo selectFirst() {
        return selectFirst(RelateInfo.class);
    }

    public List<RelateInfo> selectList() {
        return selectList(RelateInfo.class);
    }

    public Stream<RelateInfo> selectStream() {
        return selectStream(RelateInfo.class);
    }

    public Page<RelateInfo> selectPage() {
        return selectPage(RelateInfo.class);
    }

    /*###########auto#start###########*/
    public static int deleteByColumnCodeAndSourceColumnCode(String columnCode, String sourceColumnCode) {
        return forDelete().columnCode().eq(columnCode).sourceColumnCode().eq(sourceColumnCode).execute();
    }

    public static RelateInfo selectByColumnCodeAndSourceColumnCode(String columnCode, String sourceColumnCode) {
        return forSelect().columnCode().eq(columnCode).sourceColumnCode().eq(sourceColumnCode).selectFirst(RelateInfo.class);
    }

    public static <T> T selectByColumnCodeAndSourceColumnCode(String columnCode, String sourceColumnCode, Class<T> clazz) {
        return forSelect().columnCode().eq(columnCode).sourceColumnCode().eq(sourceColumnCode).selectFirst(clazz);
    }

    /*###########auto##end############*/
    /* append $conditionIndexAppender$ */
    /*###########auto#start###########*/
    public ColumnCode columnCode() {
        return new ColumnCode();
    }

    public class ColumnCode extends StringFlexColumn<RelateInfoCondition> {
        private ColumnCode() {
            super(RelateInfoCondition.this, "column_code");
        }
    }

    public CreateBy createBy() {
        return new CreateBy();
    }

    public class CreateBy extends StringFlexColumn<RelateInfoCondition> {
        private CreateBy() {
            super(RelateInfoCondition.this, "create_by");
        }
    }

    public CreateTime createTime() {
        return new CreateTime();
    }

    public class CreateTime extends LocalDateTimeFlexColumn<RelateInfoCondition> {
        private CreateTime() {
            super(RelateInfoCondition.this, "create_time");
        }
    }

    public Id id() {
        return new Id();
    }

    public class Id extends IntegerFlexColumn<RelateInfoCondition> {
        private Id() {
            super(RelateInfoCondition.this, "id");
        }
    }

    public SourceColumnCode sourceColumnCode() {
        return new SourceColumnCode();
    }

    public class SourceColumnCode extends StringFlexColumn<RelateInfoCondition> {
        private SourceColumnCode() {
            super(RelateInfoCondition.this, "source_column_code");
        }
    }

    public UpdateBy updateBy() {
        return new UpdateBy();
    }

    public class UpdateBy extends StringFlexColumn<RelateInfoCondition> {
        private UpdateBy() {
            super(RelateInfoCondition.this, "update_by");
        }
    }

    public UpdateTime updateTime() {
        return new UpdateTime();
    }

    public class UpdateTime extends LocalDateTimeFlexColumn<RelateInfoCondition> {
        private UpdateTime() {
            super(RelateInfoCondition.this, "update_time");
        }
    }

    /*###########auto##end############*/
    /* append $conditionFieldAppender$ */
}
